package net.csdn.business.discuss.api.model.dto;

import com.alibaba.fastjson2.JSON;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.csdn.business.discuss.api.enums.DiscussActionEventEnum;

import java.io.Serializable;

/**
 * @ClassName DiscussActivityEventDTO
 * @Description TODO
 * @Author zhangyl
 * @Date 2023/7/22 11:22
 */
@Data
@NoArgsConstructor
public class DiscussActivityEventDTO implements Serializable {
    private DiscussActionEventEnum action;
    private String payload;


    private DiscussActivityEventDTO(DiscussActionEventEnum action,String payload) {
        this.action = action;
        this.payload = payload;
    }

    public static <T extends BaseActivityDTO> DiscussActivityEventDTO build(DiscussActionEventEnum action, T payload) {
        return new DiscussActivityEventDTO(action, JSON.toJSONString(payload));
    }
}
